package com.jetbrains.kmpapp.utils

// 定义日志级别枚举
enum class LogLevel {
    VERBOSE, // 最详细的日志，通常用于开发调试
    DEBUG,   // 调试信息
    INFO,    // 重要事件，如应用启动、网络请求成功
    WARN,    // 潜在问题，但应用可以继续运行
    ERROR,   // 运行时错误，可能导致功能异常
    ASSERT   // 严重错误，表示不应该发生的情况
}

// 期望的 Logger 对象，包含所有日志方法
interface Logger {
    val tag: String

    fun log(level: LogLevel, message: String, throwable: Throwable? = null)

    fun verbose(message: String, throwable: Throwable? = null) = log(LogLevel.VERBOSE, message, throwable)
    fun debug(message: String, throwable: Throwable? = null) = log(LogLevel.DEBUG, message, throwable)
    fun info(message: String, throwable: Throwable? = null) = log(LogLevel.INFO, message, throwable)
    fun warn(message: String, throwable: Throwable? = null) = log(LogLevel.WARN, message, throwable)
    fun error(message: String, throwable: Throwable? = null) = log(LogLevel.ERROR, message, throwable)
    fun assert(message: String, throwable: Throwable? = null) = log(LogLevel.ASSERT, message, throwable)
}

expect fun Logger(tag: String): Logger

inline fun <reified T: Any> T.loggers(): Lazy<Logger> {
   return lazy { Logger(tag = T::class.simpleName ?: "Logger") }
}